package controller

import (
	"cmdb/base/Controller/Auth"
	"cmdb/forms"
	"cmdb/models"
)

type QueryController struct {
	Auth.PrepareController
}

func (c *QueryController) Query() {
	var user models.User
	q := c.GetString("q")
	users := user.QueryUser(q)
	c.Data["users"] = users //将数据传输到模板中
	c.Data["LoginUser"] = c.LoginUser
	c.TplName = "user/query.html"
}

func (c *QueryController) Edit() {
	form := &forms.Modify{}
	if c.Ctx.Input.IsPost() {
		err := c.ParseForm(form) //解析表单
		form.ID = c.LoginUser.ID
		if err == nil {
			err1 := c.LoginUser.ModifyUser(form)
			c.Data["errors"] = err1
		}
	}
	c.TplName = "auth/edit.html"
}
